#include "LandPhysic.h"

LandPhysic::LandPhysic()
{
}

LandPhysic::~LandPhysic()
{

}

void LandPhysic::initGameObjectWith(GamePlayScreen *_gameScreen, CCDictionary *_dict, CCDictionary *_propDict)
{
    GameObject::initGameObjectWith(_gameScreen, _dict);

    size = getSizeFromDict(_dict);
    position = getPosFromDict(_dict, CCSizeZero);
    sprite = NULL;

    b2BodyDef bodyDef;
    bodyDef.type = b2_staticBody;
    bodyDef.userData = this;
    bodyDef.position.Set(position.x / PTM_RATIO, position.y / PTM_RATIO);
    physicBody = handler->world->CreateBody(&bodyDef);

    b2FixtureDef fixtDef;
    b2PolygonShape polyShape;
    b2Vec2 center = b2Vec2(size.width / (2*PTM_RATIO), size.height / (2*PTM_RATIO));
    polyShape.SetAsBox(center.x, center.y, center, 0);
    fixtDef.shape = &polyShape;
    fixtDef.friction = _propDict->valueForKey(KEY_FRICTION)->floatValue();
    fixtDef.restitution = _propDict->valueForKey(KEY_RESTITUTION)->floatValue();
    fixtDef.density = _propDict->valueForKey(KEY_DENSITY)->floatValue();
    physicBody->CreateFixture(&fixtDef);
}

void LandPhysic::beginContact(b2Fixture *ownFixture, b2Fixture *otherFixture, b2Contact *contact)
{

}

void LandPhysic::endContact(b2Fixture *ownFixture, b2Fixture *otherFixture, b2Contact *contact)
{

}
